const express = require('express');
const router = express.Router();


router.get("/", (req, res) => {
    res.render("404");
});

router.post("/login", (req, res) => {
    return res.json({
        code: 200,
        contemt: "Hello word!"
    })
})



router.post('/ajax', function (req, res) {
    var msg = '';
    req.on('data', function (chunk) {
        msg += chunk;
        //msg.push(chunk)
    });
    req.on('end', function () {
        console.log(msg)
        var buf = new Buffer([msg]);
        console.log(buf)
        // fs.writeFile('../public/write.txt', buf, function (err) {
        //     if (err) {
        //         console.log(err)
        //     }
        // });
        res.send(buf);
        res.end();
    });
})
module.exports = router;
